package dao;

import model.BorrowDetail;
import utils.DbUtil;

import java.sql.PreparedStatement;

public class BorrowDetailDao {
    public void insertBorrowDetail(BorrowDetail bd) {
    }

    public int returnBook(BorrowDetail detail) {
        try {
            String sql = "update borrow_detail set status=?,return_time=? where id=?";
            PreparedStatement ps = (PreparedStatement) DbUtil.con.prepareStatement(sql);
            ps.setInt(1, detail.getStatus());
            ps.setLong(2, detail.getReturnTime());
            ps.setInt(3, detail.getBorrowId());
            return ps.executeUpdate();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return 0;
    }
}
